using System;
using System.Collections.Generic;
using System.Text;

namespace sCicero
{
    public class GlobalEvent
    {
        public event sCiceroMessageEvent DatabaseSaveMessage;

        public void Raise_DatabaseSaveMessage(object sender, string sInfo, Errorcode oErrorCode)
        {
            if (DatabaseSaveMessage != null)
                DatabaseSaveMessage(sender, new sMessageEventArgs(sInfo, oErrorCode));
        }

        public delegate void sCiceroMessageEvent(object sender, sMessageEventArgs e);

        public class sMessageEventArgs : EventArgs
        {

            public string sInfo;
            public object oObject;
            public sMessageEventArgs(string e_sInfo, object e_oObject)
            {
                sInfo = e_sInfo;
                oObject = e_oObject;
            }
        }

        public event sCiceroDataBaseEvent DataBaseStatus;

        public void Rasie_DataBaseStatus(object sender, eDataBaseStatus oStatus)
        {
            if (DataBaseStatus != null)
                DataBaseStatus(sender, new sDataBaseEventArgs(oStatus));
        }

        public delegate void sCiceroDataBaseEvent(object sender, sDataBaseEventArgs e);

        public class sDataBaseEventArgs : EventArgs
        {

            public eDataBaseStatus oDataBaseStatus;
            public sDataBaseEventArgs(eDataBaseStatus e_oDataBaseStatus)
            {
                oDataBaseStatus = e_oDataBaseStatus;
            }
        }

        public enum eDataBaseStatus : int
        {
            SAVED = 0,
            SAVING_CHANGES,
            CHANGES_NOT_COMMITTED
        };
    }
    public class GenericList<T>
    {
        void Add(T input) { }
    }
    public class Event : Base
    {
        private bool m_bOverRideControlClose = false;

        public bool OverRideControlClose
        {
            get { return m_bOverRideControlClose; }
            set { m_bOverRideControlClose = value; }
        }


        public event sCiceroEvent NavButton_OnClick;
        public event sCiceroEvent StudentCreated;
        public event sCiceroEvent StudentDeleted;
        public event sCiceroEvent ClassCreated;
        public event sCiceroEvent TestCreated;
        public event sCiceroEvent WorkareaCreated;
        public event sCiceroEvent SubjectCreated;
   

        public event sCiceroRequestEvent PeriodCreated;
        public event sCiceroRequestEvent NewResultRequest;
        public event sCiceroRequestEvent NewStudentRequest;
        public event sCiceroRequestEvent NewTestRequest;
        public event sCiceroRequestEvent NewTabPageSelectedRequest;
        public event sCiceroRequestEvent NewDebugRequest;
        public event sCiceroRequestEvent NewDocumentRequest;
        public event sCiceroRequestEvent ShowFormRequest;
        public event sCiceroRequestEvent DestroyFormRequest;
        public event sCiceroRequestEvent SuppressSaveRequest;
        public event sCiceroRequestEvent RollbackRequest;
        public event sCiceroRequestEvent ErrorRequest;

        public event sCiceroUpdateEvent UpdateRequest;
        public event sCiceroUpdateEvent ControlCloseRequest;
        public event sCiceroUpdateEvent DataBaseEvent;





        public void Raise_NewErrorRequest(object sender, Errorcode oE, string sError)
        {
            if (ErrorRequest != null)
                ErrorRequest(sender, new sRequestEventArgs(0, 0, sError));
        }

        public void Raise_NewSuppressSaveRequest(object sender, bool bSuppressSave)
        {
            if (SuppressSaveRequest != null)
                SuppressSaveRequest(sender, new sRequestEventArgs(0, 0, (bSuppressSave ? "true" : "false")));
        }


        public void Raise_NewRollbackRequest(object sender)
        {
            if (RollbackRequest != null)
                RollbackRequest(sender, new sRequestEventArgs(0, 0, ""));
        }


        
        public void Raise_NewTabPageSelectedRequest(object sender, string sTabPageIdentifier)
        {
            if (NewTabPageSelectedRequest != null)
                NewTabPageSelectedRequest(sender, new sRequestEventArgs(0, 0, sTabPageIdentifier));
        }

        public void Raise_ControlCloseRequest(object sender, string sInfo, bool bUpdate)
        {
            if (ControlCloseRequest != null)
                ControlCloseRequest(sender, new sUpdateEventArgs(sInfo, bUpdate));
        }

        public void Raise_NewTestRequest(object sender, int nSubjectId)
        {
            if (NewTestRequest != null)
                NewTestRequest(sender, new sRequestEventArgs(nSubjectId, 0, null));
        }
        public void Raise_NewDocumentRequest(object sender, string sDocumentName)
        {
            if (NewDocumentRequest != null)
                NewDocumentRequest(sender, new sRequestEventArgs(0, 0, sDocumentName));
        }


        public void Raise_NewDebugRequest(object sender)
        {
            if (NewDebugRequest != null)
                NewDebugRequest(sender, new sRequestEventArgs(0, 0, null));
        }

        public void Raise_DestroyFormRequest(object sender, string sTypeOf)
        {
            if (DestroyFormRequest != null)
                DestroyFormRequest(sender, new sRequestEventArgs(0, 0, sTypeOf));
        }

        public void Raise_ShowFormRequest(object sender, int nBaseId, string sTypeOf)
        {
            if (ShowFormRequest != null)
                ShowFormRequest(sender, new sRequestEventArgs(nBaseId, -1, sTypeOf));
        }
        public void Raise_ShowFormRequest(object sender, int nBaseId, int nExtraId, string sTypeOf)
        {
            if (ShowFormRequest != null)
                ShowFormRequest(sender, new sRequestEventArgs(nBaseId, nExtraId, sTypeOf));
        }

        public void Raise_DataBaseEvent(object sender, string sInfo)
        {
            if (DataBaseEvent != null)
                DataBaseEvent(sender, new sUpdateEventArgs(sInfo, false));
        }
        public void Raise_UpdateRequest(object sender, string sInfo, bool bUpdate)
        {
            if (UpdateRequest != null)
                UpdateRequest(sender, new sUpdateEventArgs(sInfo, bUpdate));
        }

        public void Raise_NewStudentRequest(object sender, int nClassId)
        {
            if (NewStudentRequest != null)
                NewStudentRequest(sender, new sRequestEventArgs(nClassId,0,null));
        }

        public void Raise_NewResultRequest(object sender, int nClassId)
        {
            if (NewResultRequest != null)
                NewResultRequest(sender, new sRequestEventArgs(nClassId,0,null));
        }

        public void Raise_ClassCreated(object sender, string sClassName)
        {
            if (ClassCreated != null)
                ClassCreated(sender, new sCiceroButtonEventArgs(sClassName, ""));
        }

        public void Raise_StudentDeleted(object sender, string sStudentName, string sClassName)
        {
            if (StudentDeleted != null)
                StudentDeleted(sender, new sCiceroButtonEventArgs(sStudentName, sClassName));
        }

        public void Raise_StudentCreated(object sender, string sStudentName, string sClassName)
        {
           if (StudentCreated != null)
               StudentCreated(sender, new sCiceroButtonEventArgs(sStudentName, sClassName));
        }

        public void Raise_PeriodCreated(object sender, string sPeriodName, int nPeriodId)
        {
            if (PeriodCreated != null)
                PeriodCreated(sender, new sRequestEventArgs(nPeriodId, 0, sPeriodName));
        }

        public void Raise_TestCreated(object sender, string sTestname, string sSubject)
        {
            if (TestCreated != null)
                TestCreated(sender, new sCiceroButtonEventArgs(sTestname, sSubject));
        }

        public void Raise_SubjectCreated(object sender, string sSubject)
        {
            if (SubjectCreated != null)
                SubjectCreated(sender, new sCiceroButtonEventArgs(sSubject, ""));
        }


        public void Raise_WorkareaCreated(object sender, string sWorkareaName)
        {
            if (WorkareaCreated != null)
                WorkareaCreated(sender, new sCiceroButtonEventArgs(sWorkareaName, ""));
        }


        public void Raise_NavButton_OnClick(object sender, string sIdentifier, string sCommand)
        {
            if (NavButton_OnClick != null)
                NavButton_OnClick(sender, new sCiceroButtonEventArgs(sIdentifier, sCommand));
        }

        public delegate void sCiceroEvent(object sender, sCiceroButtonEventArgs e);
        public delegate void sCiceroRequestEvent(object sender, sRequestEventArgs e);
        public delegate void sCiceroUpdateEvent(object sender, sUpdateEventArgs e);

        public class sUpdateEventArgs : EventArgs
        {

            public string sInfo;
            public bool bUpdateControls;
            public sUpdateEventArgs(string e_sInfo, bool e_bUpdateControls)
            {
                sInfo = e_sInfo;
                bUpdateControls = e_bUpdateControls;
            }
        }

        public class sRequestEventArgs : EventArgs
        {
            
            public int nParam1;
            public int nParam2;
            public string sParam1;
            public sRequestEventArgs(int e_nParam1, int e_nParam2, string e_sParam1)
            {
                nParam1 = e_nParam1;
                nParam2 = e_nParam2;
                sParam1 = e_sParam1;
            }

        }

        public class sCiceroButtonEventArgs : EventArgs
        {
            public string sIdentifier;
            public string sCommand;
            public sCiceroButtonEventArgs(string e_sIdentifier, string e_sCommand)
            {
                sIdentifier = e_sIdentifier;
                sCommand = e_sCommand;
            }
        }
    }
}
